#ifndef __ENCODER_H
#define __ENCODER_H


#include "stm32f1xx_hal.h"
#include "stdint.h"

#define MOTER_NUMBER    4U  //4个电机
#define REDUCTION_RATIO 14U //减速比
#define ENCODER_PCR     13U //编码器线数

enum _encoder_dir{
	DIR_NONE = 0,
	DIR_FORWARD,
	DIR_BACKWARD,
};

typedef struct _encoder_t
{
	int16_t encoder_M_last[MOTER_NUMBER];//上一次获取的定时器值
	int32_t encoder_M[MOTER_NUMBER];     //码盘累计值
	int16_t  speed_M[MOTER_NUMBER];      //速度 (plus/ms -> 1ms多少脉冲值->等效于速度)
	uint8_t dir[MOTER_NUMBER];           //电机方向
} encoder_t;

extern encoder_t encoder_dev;
extern void encoder_timer_cnt(void);

#endif

